<?php

namespace App\Http\Model;

class User extends Base
{
    protected $hidden = ['password', 'is_active', 'system_type', 'system_version', 'updated_at'];
    protected $fillable = array('mobile', 'nickname', 'avatar', 'token');

    public function getAddressAttribute($value)
    {
        return json_decode($value, true);
    }

    public function getAvatarAttribute($value)
    {
        if (empty($value)) return $value;

        return env('CDN_DOMAIN') . $value;
    }

    public function getCreatedAtAttribute($date)
    {
        return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->timestamp;
    }

}
